package com.three.iot.rest;

import com.three.iot.jdbc.mapper.TCacheInfoMapper;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.actuate.endpoint.web.annotation.RestControllerEndpoint;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.transaction.annotation.EnableTransactionManagement;

import javax.annotation.Resource;
import java.util.Date;
import java.util.TimeZone;

@SpringBootApplication
@ComponentScan("com.three.iot")
@MapperScan(value = {"com.three.iot.jdbc.mapper"})
@EnableTransactionManagement
@EnableScheduling
public class IotRestApplication {

    @Resource
    private TCacheInfoMapper tCacheInfoMapper;

    public static void main(String[] args) {
        System.out.println(TimeZone.getDefault());
        System.out.println(new Date());
       SpringApplication.run(IotRestApplication.class, args);
    }

    @Scheduled(fixedDelay = 30000 ) //每30秒运行一次
    public void scheduleDelKey() {
        tCacheInfoMapper.deleteWhenIsOverTime();
    }

}
